function ajaxGet(page,callback)
{
	$.get(page, '', function(data){
		processResponse(data);
		if(callback != undefined && callback != null)
		{
			callback(data);
		}
	}, 'json');
}

function ajaxPost(page,data,callback)
{
	$.post(page, data, function(data){
		processResponse(data);
		if(callback != undefined && callback != null)
		{
			callback(data);
		}
	}, 'json');
}

function processResponse(data)
{
	if(data.title != undefined)
	{
		setTitle(data.title);
	}
	
	if(data.navi != undefined)
	{
		showNav(data.navi);
	}
}

function setTitle(title)
{
	document.title = title;
}

function showNav(navi)
{
	var navElem = $('#navi');
	navElem.html('');

	for(var i in navi)
	{
		if(navi[i].type == 'E_HREF')
		{
			navElem.append('<a href="'+navi[i].link+'">'+navi[i].title+'</a>&nbsp;');
		}
		else
		{
			navElem.append('<a href="#" onClick="'+navi[i].link+'">'+navi[i].title+'</a>&nbsp;');
		}
	}
}

function showLogin()
{
	$('#content').html('<form><input id="username" type="text" name="username"/><br/><input id="password" type="password" name="password"/><br/><input type="submit" value="Login" onClick="doLogin(); return false;"/></form>');
}

function doLogin()
{
	var uname = $('#username')[0].value;
	var pass = $('#password')[0].value;
	
	ajaxPost('forum/core/user/user.php',{'action':'login','username':uname,'password':pass},function(resp){alert('ok');});
}